﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using PMS.Client.Entities;
using PMS.Client.IDAL;

namespace PMS.Client.DAL
{
    public class BaseInfoAccess : WebAccess, IBaseInfoAccess
    {
        public BaseInfoAccess(GlobalValues globalValues) : base(globalValues)
        {
        }

        public string CancelState(int id)
        {
            string uri = $"/api/bi/cancel/{id}";
            return this.Get(uri);
        }

        public string DeleteInfo(int id)
        {
            string uri = $"/api/bi/delete/{id}";
            return this.Get(uri);
        }

        public string GetInfoPage(string key, int index, int size)
        {
            key = string.IsNullOrEmpty(key) ? "none" : key;
            string uri = $"/api/bi/page/{key}/{index}/{size}";
            return this.Get(uri);
        }

        public string PublishState(int id)
        {
            string uri = $"/api/bi/publish/{id}";
            return this.Get(uri);
        }

        public string RevokeState(int id)
        {
            string uri = $"/api/bi/revoke/{id}";
            return this.Get(uri);
        }

        public string UpdateInfo(string infoJson)
        {
            string uri = "/api/bi/update";

            StringContent content = new StringContent(infoJson);
            content.Headers.ContentType =
                new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");

            return this.Post(uri, content);
        }
    }
}
